package com.ruoyi.system.api;

import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.domain.SysUserAccount;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户服务
 *
 * @author ruoyi
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @return 结果
     */
    @GetMapping(value = "/user/info/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username);

    /**
     * 获取用户列表
     *
     * @param user
     * @return
     */
    @GetMapping(value = "/user/listInfo")
    R<List<SysUser>> getUserList(SysUser user);

    /**
     * 获取对应角色的用户
     *
     * @param roleKey
     * @return
     */
    @GetMapping(value = "/user/listUserByRoleKey")
    R<List<SysUser>> getUserListByRoleKey(String roleKey);

    @PostMapping(value = "/sysUserAccount/info")
    R<SysUserAccount> getUserAccountInfo(SysUserAccount userAccount);

//    @GetMapping(value = "/sysUserAccount/info/{phoneNumber}")
//    public R<SysUserAccount> getUserAccountInfoByPhone(@PathVariable("phoneNumber") String phoneNumber);

    @PostMapping(value = "/sysUserAccount/add")
    public R addUserAccountInfo(@RequestBody SysUserAccount userAccount);

    @PostMapping(value = "/sysUserAccount/update")
    public R updateUserAccountInfo(@RequestBody SysUserAccount userAccount);

}
